<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>用户列表</title>
<!--公共样式开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/reset.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/common.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Plugins/FontAwesome/css/font-awesome.min.css">
<!--公共样式结束-->
<!--公共JS开始-->
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.min.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.timer.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/common.js"></script>
<!--公共JS结束-->
<!--数据列表插件开始-->
<link href="{$NOW_THEME_URL}/Assets/Plugins/ContextMenu/src/jquery.contextMenu.css" rel="stylesheet" type="text/css" />
<script src="{$NOW_THEME_URL}/Assets/Plugins/ContextMenu/src/jquery.ui.position.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Plugins/ContextMenu/src/jquery.contextMenu.js"></script>
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Plugins/Etgrid/Css/etgrid.css">
<script src="{$NOW_THEME_URL}/Assets/Plugins/Etgrid/Js/etgrid.js"></script>
<!--数据列表插件结束-->
<!--ZTree开始-->
<link rel="stylesheet" href="{$NOW_THEME_URL}/Assets/Plugins/ZTree/css/zTreeStyle/zTreeStyle.css" type="text/css">
<include file="treeRole" />
<script type="text/javascript" src="{$NOW_THEME_URL}/Assets/Plugins/ZTree/js/jquery.ztree.core-3.5.js"></script>
<!--ztree结束-->
<style type="text/css">
	body {
		overflow:hidden;
	}
	.table_box {
	}
</style>
</head>

<body>
	<div class="page_header">
		<div class="table_tool">
			<ul class="clearfix">			
				<li class="memberDel btn"><i class="icon-remove"></i> 批量删除</li>
				<li class="line"></li>
				<li class="openwin btn" etitle="新增用户" eheight="400px" ewidth="900px" ehref="{:U('Company/adminAdd')}"  id="Company_adminAdd"><i class="icon-plus"></i>新增用户</li>
				<li class="line"></li>
				<li class="openwin btn" etitle="角色管理" eheight="400px" ewidth="600px" ehref="{:U('Company/role')}"      id="Company_role"><i class="icon-group"></i>角色管理</li>
				<li class="line"></li>
				<!-- <li class="openwin btn" etitle="门店管理" eheight="400px" ewidth="600px" ehref="{:U('Company/outlet')}"    id="Company_outlet"><i class="icon-trello"></i>门店管理</li>
				<li class="line"></li> -->
				<li class="openwin btn" etitle="我的快捷菜单" eheight="400px" ewidth="600px" ehref="{:U('Public/addApp')}"   id="Public_addApp"><i class="icon-signin"></i>我的快捷方式</li>
			</ul>
		</div>
		<!-- <div class="search_box">
			<input type="text" id="keywords" class="form_ele w200" placeholder="请输入用户名、姓名、手机号码搜索"/>
			<span id="doSearch" class="doSearch">
				<i class="icon-search"></i> 搜索
			</span>
		</div> -->
	</div>
	<div class="yhlist clearfix">
		<ul id="tree" class="ztree" style="width:170px;overflow:auto;float:left;"></ul>
		<div class="table_box" style="float:left;border-left:1px solid #999;">
		</div>
	</div>
</body>
<script type="text/javascript">
	var listConfig = {
			blockBox : '.table_box',
			blockBoxHeight : 'window',
			blockBoxWidth : 'adaptive',
			adaptiveFixedWidth : '181',
			jsonUrl : '__URL__/admin/role/{$roleid}',
			where : '',
			getWhere : function(){
				var    keywords = $('#keywords').val();
				return keywords;
			},
			widthType : 'thw', //thw-标题标准宽度、tdw-数据单元标准宽度、auto-随数据单元宽度
			pageNum : 10,
			nowPage : 1,
			orderName : "addtime",
			orderDirection : "desc",
			dataContextMenuOpen: true, //是否开启数据行右键菜单
			dataContextMenu: function(){
				$.contextMenu({
					selector: '.et_tbody tr',
					items: {
						"edit": {
							name: "修改", 
							icon: "edit",
							callback: function(key, options) {
								var href   = '__URL__/adminEdit/id/'+$(this).attr('rowid');
								var width  = '900px';
								var height = '500px';
								var title  = '修改用户';
								openDialog('Company_adminEdit',href,width,height,title);
							}
						},
						/* "delete": {
							name: "删除", 
							icon: "del",
							callback: function(key, options) {
								var title =  $(this).children('td[fieldname="title"]').html();																
								$('.et_tfoot .page_refresh').click();
							}
						}, */
						"disabled": {
							name: "禁用", 
							icon: "del",
							callback: function(key, options) {
								var href = "__URL__/adminActive";
								var id   = $(this).attr('rowid');
								$.post(href,{id:id,status:2},function(data){
									if(data.status == 1){
										$('.et_tfoot .page_refresh').click();
									}else{
										windowApi.lhgdialog.alert(data.info);
									}
								})
							}
						},
						"active": {
							name: "启用", 
							icon: "del",
							callback: function(key, options) {
								var href = "__URL__/adminActive";
								var id   = $(this).attr('rowid');
								$.post(href,{id:id,status:1},function(data){
									if(data.status == 1){
										$('.et_tfoot .page_refresh').click();
									}else{
										windowApi.lhgdialog.alert(data.info);
									}
								})
							}
						}
					}
				});
			},
			colModel : [
				{
					display : 'checkbox',
					name : 'id',
					sortable : true,
					myclass : 'center',
					edit : false,
					width : '20px'
				},
				{
					display : '所属城市',
					name : 'city',
					sortable : false,
					myclass : 'center',
					edit : false
				},
				{
					display : '用户帐号',
					name : 'username',
					sortable : true,
					myclass : 'center',
					edit : false
				},
				
				/*{
					display : '工号',
					name : 'jobno',
					sortable : true,
					myclass : 'center',
					edit : false
				},*/
				{
					display : '姓名',
					name : 'realname',
					sortable : true,
					myclass : 'center',
					edit : false
				},
				{
					display : '手机号码',
					name : 'mobile',
					sortable : true,
					myclass : 'center',
					edit : false
				},
				{
					display : '状态',
					name : 'status',
					sortable : false,
					myclass : 'center',
					edit : false
				}
			]
		};
	
	//实例化列表
	var tableList = $('.table_box').EtGrid(listConfig);
	//tableList.erefresh();
	
	//批量删除
	$('.memberDel').on('click',function(){
		var val  = tableList.getChecked();
		var msg = "确认要将选中的用户删除吗？";
		
		if(val){
			windowApi.lhgdialog.confirm(msg, function(){
				$.get("{:U('Company/adminDel')}",{val:val},function(data){
					if(data.status==1){
						$('.et_tfoot .page_refresh').click(); //刷新加载
					}else{
						windowApi.lhgdialog.alert(data.info,function(){return;});
					}
				});
			},function(){return;});
		}else{
			windowApi.lhgdialog.alert('请选择需要删除的用户！');
		}
	});
	
	//移动到分组
	$('.memberGroup .submenu>li').on('click',function(){
		var val = '';
		$('.et_tbody .chk_item:checked').each(function(index, element) {
			if(val){
				val += ','+$(this).val();
			}else{
				val += $(this).val();
			}
		});
		
		alert('将Id为'+val+'的数据移动到Id为'+$(this).attr('toid')+'的会员分组');
	});
	
	//打开统计图表
	$('.memberChart').on('click',function(){
		var href = 'memberAdd.html?id='+$(this).attr('rowid');
		var width = '900px';
		var height = '500px';
		var title = '统计图表';
		openDialog('memberChart',href,width,height,title);
	});
</script>
</html>
